﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NStore.Domain;
using NStore.Infrastructure.Repositories;
using NStore.Infrastructure.Security;
using Rhino.Mocks;

namespace NStore.Infrastructure.Tests.Security
{
    [TestClass]
    public class NStoreRoleProviderTest
    {
        [TestMethod]
        public void GetRolesForUser_GivenUsernameWhenCallThenReturnRoles()
        {
            User stubUser = MockRepository.GenerateStub<User>();
            stubUser.Roles.Add("admin");
            UserRepository stubRepository = MockRepository.GenerateStub<UserRepository>();
            stubRepository.Stub(r => r.GetByUserName("username")).Return(stubUser);
            NStoreRoleProvider nStoreRoleProvider = new NStoreRoleProvider(stubRepository);

            string[] rolesForUser = nStoreRoleProvider.GetRolesForUser("username");
            
            Assert.IsTrue(rolesForUser.Contains("admin"));
        }
    }
}
